﻿using System;
using System.IO;
using OpenLS.Spreadsheet.Expressions;

namespace OpenLS.Spreadsheet.Formats.Biff.Records
{
    internal class CFGradientInterpItem
    {
        private CFVO cfvoInterp;
        private double numDomain;

        public CFGradientInterpItem(ConditionalFormatValueObject conditionalFormatValueObject, double value)
        {
            cfvoInterp = new CFVO(conditionalFormatValueObject);
            this.numDomain = value;
        }

        public CFGradientInterpItem()
        {
        }

        public void Read(BinaryReader reader)
        {
            this.cfvoInterp = new CFVO();
            this.cfvoInterp.Read(reader);
            this.numDomain = reader.ReadDouble();
        }

        public void Write(BinaryWriter writer)
        {
            this.cfvoInterp.Write(writer);
            writer.Write(numDomain);
        }

        public ConditionalFormatValueObject ToCondition(BiffReaderWorksheetContext context)
        {
            return cfvoInterp.ToCondition(context);
        }
    }
}